package cn.wizzer.app.web.modules.controllers.platform.user.account;

import cn.wizzer.app.user.modules.models.enums.BizTypeEnum;
import cn.wizzer.app.user.modules.services.account.UserAccountRecordService;
import cn.wizzer.framework.base.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

@IocBean
@At("/platform/user/account/record")
public class AccountRecordController {
    private static final Log log = Logs.get();

//    @Inject
//    private CommonDBService commonDBService;

    @Inject
    @Reference
    private UserAccountRecordService accountRecordService;

    @At("")
    @Ok("beetl:/platform/user/account/record/index.html")
    @RequiresPermissions("user.account.record")
    public void index() {

    }

    @At
    @Ok("json:full")
    @RequiresPermissions("user.account.record")
    public Object data(@Param("userId") String userId, BizTypeEnum bizType,
                       @Param("searchDate") String[] searchDate,
                       @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize) {
        return Result.success().addData(accountRecordService.listPage(pageNumber, pageSize, userId, bizType, searchDate));
    }

    @At
    @Ok("json:full")
    @RequiresPermissions("user.account.record")
    public Object getBizType() {
        return Result.success().addData(BizTypeEnum.toList());
    }

}
